<!--该组件会自动上传文件，返回上传成功的文件名-->

<script setup lang="ts">

import ImageUpload from "~/components/ai/ImageUpload.vue";
import LabelBase from "~/components/ai/LabelBase.vue";
interface Props {
  title?:string
}
const props=withDefaults(defineProps<Props>(),{
  title:"请上传图片"
})

const uploadfile=ref<any>(null)
watch(uploadfile,async () => {
  await ComfyUI.Initalize()
  //将文件上传
  //如果没有启动OSS，则使用预分配服务器
  const _path = await ComfyUI.uploadImage(uploadfile.value[0].originFileObj)
  if(_path){
    uploadpath.value=_path
    useSnackbarStore().showSuccessMessage(`上传成功${_path}`)
  }
})
//上传成功后的路径
const uploadpath=defineModel({
  default:""
})

</script>

<template>
  <v-sheet  class="pt-2">
    <label-base>请上传图片</label-base>
  <image-upload v-model:uploadfile="uploadfile" :decription="title"></image-upload>
  </v-sheet>
</template>

<style scoped lang="scss">

</style>